package com.example.seakdreamandroid.cardQuest;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.CompositePageTransformer;
import androidx.viewpager2.widget.MarginPageTransformer;
import androidx.viewpager2.widget.ViewPager2;


import android.os.Bundle;

import android.view.View;
import android.widget.Button;


import com.example.seakdreamandroid.R;
import com.youth.banner.transformer.ScaleInTransformer;


import java.util.ArrayList;

public class CardQuestionActivity extends AppCompatActivity {
    ArrayList<SwipeCardBean> mDatas = new ArrayList<>();
    ViewPager2 viewPager2;
    Button former;
    Button black;
    ArrayList<Integer> data = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_card_question);

        initData();
        initView();

        MyAdapter myAdapter = new MyAdapter();
        myAdapter.setList(mDatas);
        myAdapter.setViewPager2(viewPager2);
        myAdapter.setCardQuestionActivity(this);
        viewPager2.setAdapter(myAdapter);
        RecyclerView recyclerView = (RecyclerView) viewPager2.getChildAt(0);
        int padding = 50;
        recyclerView.setPadding(padding, 0, padding, 0);
        recyclerView.setClipToPadding(false);
        CompositePageTransformer compositePageTransformer = new CompositePageTransformer();
        compositePageTransformer.addTransformer(new ScaleInTransformer());
        compositePageTransformer.addTransformer(new MarginPageTransformer(10));
        viewPager2.setPageTransformer(compositePageTransformer);
        viewPager2.setOffscreenPageLimit(2);
        viewPager2.setUserInputEnabled(false);

        former.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                viewPager2.beginFakeDrag();
                viewPager2.fakeDragBy(600f);
                viewPager2.endFakeDrag();
            }
        });

        black.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


    }



    private void initView() {
        black = findViewById(R.id.black);
        former = findViewById(R.id.former);
        viewPager2 = findViewById(R.id.view_pager2);
    }

    private void initData() {
        SwipeCardBean m1 = new SwipeCardBean();
        m1.setNumber("1/10");
        m1.setTitle("你的年龄是？");
        m1.setSelectA("A   |   18岁以下");
        m1.setSelectB("B   |   18~24岁");
        m1.setSelectC("C   |   25~35岁");
        m1.setSelectD("D   |   36~50岁");
        m1.setSelectE("E   |   50岁以上");
        m1.setSelect("A");

        SwipeCardBean m2 = new SwipeCardBean();
        m2.setNumber("2/10");
        m2.setTitle("您对现在的睡眠有多少忧虑：");
        m2.setSelectA("A   |   完全没有");
        m2.setSelectB("B   |   少许");
        m2.setSelectC("C   |   颇为");
        m2.setSelectD("D   |   非常");
        m2.setSelectE("E   |   非常大");
        m2.setSelect("A");

        SwipeCardBean m3 = new SwipeCardBean();
        m3.setNumber("3/10");
        m3.setTitle("你入睡困难的严重程度是：");
        m3.setSelectA("A   |   无");
        m3.setSelectB("B   |   轻度");
        m3.setSelectC("C   |   中度");
        m3.setSelectD("D   |   重度");
        m3.setSelectE("E   |   非常严重");
        m3.setSelect("A");

        SwipeCardBean m4 = new SwipeCardBean();
        m4.setNumber("4/10");
        m4.setTitle("你过早醒来的严重程度是：");
        m4.setSelectA("A   |   无");
        m4.setSelectB("B   |   轻度");
        m4.setSelectC("C   |   中度");
        m4.setSelectD("D   |   重度");
        m4.setSelectE("E   |   非常严重");
        m4.setSelect("A");

        SwipeCardBean m5 = new SwipeCardBean();
        m5.setNumber("5/10");
        m5.setTitle("你对自己当前的睡眠模式满意吗？");
        m5.setSelectA("A   |   很满意");
        m5.setSelectB("B   |   满意");
        m5.setSelectC("C   |   一般");
        m5.setSelectD("D   |   不满意");
        m5.setSelectE("E   |   很不满意");
        m5.setSelect("A");

        SwipeCardBean m6 = new SwipeCardBean();
        m6.setNumber("6/10");
        m6.setTitle("你的睡眠问题对白天的影响程度是：");
        m6.setSelectA("A   |   完全没有");
        m6.setSelectB("B   |   少许");
        m6.setSelectC("C   |   颇为");
        m6.setSelectD("D   |   非常");
        m6.setSelectE("E   |   非常大");
        m6.setSelect("A");

        SwipeCardBean m7 = new SwipeCardBean();
        m7.setNumber("7/10");
        m7.setTitle("你的睡眠问题对生活有多大影响：");
        m7.setSelectA("A   |   没有");
        m7.setSelectB("B   |   一点");
        m7.setSelectC("C   |   有些");
        m7.setSelectD("D   |   较多");
        m7.setSelectE("E   |   很多");
        m7.setSelect("A");

        SwipeCardBean m8 = new SwipeCardBean();
        m8.setNumber("8/10");
        m8.setTitle("你担心自己当前的睡眠问题吗？");
        m8.setSelectA("A   |   一点也不担心");
        m8.setSelectB("B   |   不太担心");
        m8.setSelectC("C   |   有些担心");
        m8.setSelectD("D   |   比较担心");
        m8.setSelectE("E   |   非常担心");
        m8.setSelect("A");

        SwipeCardBean m9 = new SwipeCardBean();
        m9.setNumber("9/10");
        m9.setTitle("失眠问题困扰你多久了？");
        m9.setSelectA("A   |   不到1个月");
        m9.setSelectB("B   |   1~3个月");
        m9.setSelectC("C   |   4~6个月");
        m9.setSelectD("D   |   7个月~1年");
        m9.setSelectE("E   |   1年以上");
        m9.setSelect("A");

        SwipeCardBean m10 = new SwipeCardBean();
        m10.setNumber("10/10");
        m10.setTitle("早晨醒来时的身体状况：");
        m10.setSelectA("A   |   头脑神清气爽");
        m10.setSelectB("B   |   头脑较清醒, 与平时相似");
        m10.setSelectC("C   |   情绪一般");
        m10.setSelectD("D   |   情绪稍差");
        m10.setSelectE("E   |   情绪很坏");
        m10.setSelect("A");
        mDatas.add(m1);
        mDatas.add(m2);
        mDatas.add(m3);
        mDatas.add(m4);
        mDatas.add(m5);
        mDatas.add(m6);
        mDatas.add(m7);
        mDatas.add(m8);
        mDatas.add(m9);
        mDatas.add(m10);

    }
}